<?php

use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Auth;

return [
    'title'=>'站点设置',
    'permission'=>function(){
        return Auth::user()->hasRole('Founder');
    },
    'edit_fields'=>[
        'site_name'=>[
            'title'=>'站点名称',
            'type'=>'text',
            'limit'=>50
        ],
        'contact_email'=>[
            'title'=>'联系人邮箱',
            'type'=>'text',
            'limit'=>50
        ],
        'seo_description'=>[
            'title'=>'SEO - Description',
            'type'=>'textarea',
            'limit'=>250
        ],
        'seo_keywords'=>[
            'title'=>'SEO - Keywords',
            'type'=>'textarea',
            'limit'=>250
        ],
    ],
    'rules'=>[
        'site_name'=>'required|max:50',
        'contact_email'=>'email'
    ],
    'messages'=>[
        'site_name.required'=>'请填写站点名称',
        'contact_email.email'=>'联系邮箱格式不正确'
    ],
    'before_save'=>function(&$data){
        if(strpos($data['site_name'],'Powered by Luntan1') === false){
            $data['site_name'] .= '- Powered by Luntan1';
        }
    },
    'actions'=>[
        'clear_cache'=>[
            'title'=>'更新系统缓存',
            'messages'=>[
                'active'=>'正在清理缓存...',
                'success'=>'缓存已清空',
                'error'=>'清空缓存时出错'
            ],
            'action'=>function(&$data){
                Artisan::call('cache:clear');
                return true;
            }
        ]
    ]
];
